package koala.kuangjiademo.data;

import android.support.annotation.Nullable;

import com.wwgps.ect.util.Helper;

import java.io.Serializable;

public class User implements Serializable {
    public String token;
    public int id;
    private EmployeeInfo employeeInfo;

    public void setEmployeeInfo(EmployeeInfo employeeInfo) {
        this.employeeInfo = employeeInfo;
    }

    public void update(@Nullable User user) {
        if (user != null) {
            Helper.loadData(user, this, User.class);
        } else {
            token = null;
            id = 0;
            employeeInfo = null;
        }
    }

    @Nullable
    public String getName() {
        return employeeInfo != null ? employeeInfo.employeename : null;
    }

    @Nullable
    public String getPhoto() {
        return employeeInfo != null ? employeeInfo.headiconpath : null;
    }

    public String getFamilyName() {
        String name = getName();
        return name != null ? name.substring(0, 1) : "我";
    }

    public String photoFile;

    public static class EmployeeInfo implements Serializable {
        private String employeename;
        private String headiconpath;
    }

    public static class Response extends ResponsePacket<User> {
    }

    public static class PhotoResponse extends ResponsePacket<EmployeeInfo> {
    }

}
